package com.lian.pet.controller;

import com.lian.pet.common.basic.response.AppResp;
import com.lian.pet.domain.dto.AddPetEventDTO;
import com.lian.pet.domain.dto.QueryPetEventDTO;
import com.lian.pet.domain.vo.PetEventVO;
import com.lian.pet.service.PetEventService;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Slf4j
@RequestMapping("petevent")
@RestController
@AllArgsConstructor
public class PetEventController {
    private final PetEventService petEventService;

    /**
     * 新增活动记录
     * @param req
     * @param petId
     */
    @PostMapping("/add")
    public AppResp<Void> addpetEvent(@RequestBody AddPetEventDTO req, @RequestParam("petId") Integer petId) {
        petEventService.addPetEvent(req, petId);
        return AppResp.succeed(null);
    }

    /**
     * 查询活动记录列表
     * @param req
     * @param petId
     * @return
     */
    @PostMapping("/queryList")
    public AppResp<List<PetEventVO>> queryPetEvent(@RequestBody QueryPetEventDTO req, @RequestParam("petId") Integer petId) {
        return AppResp.succeed(petEventService.queryPetEvent(req, petId));
    }

    /**
     * 查询活动记录信息
     * @param id
     * @return
     */
    @GetMapping("/getById")
    public AppResp<PetEventVO> getpetEventById(@RequestParam("id") Integer id) {
        return AppResp.succeed(petEventService.getPetEvent(id));
    }

    /**
     * 删除活动记录信息
     * @param id
     */
    @GetMapping("/deleteById")
    public AppResp<Integer> deleteById(@RequestParam("id") Integer id) {
        petEventService.deletePetEvent(id);
        return AppResp.succeed(1);
    }

    /**
     * 修改活动记录信息
     * @param req
     * @param id
     * @return
     */
    @PostMapping("/updateById")
    public AppResp<Void> updateById(@RequestParam("id") Integer id, @RequestBody AddPetEventDTO req) {
        petEventService.updatePetEvent(id, req);
        return AppResp.succeed(null);
    }

}
